package org.kisekiproject.evaluator.nodes {
	import flash.events.Event;
	import flash.events.EventDispatcher;

	/**
	 * Object indirection.
	 */
	public class IndirectionNode extends EventDispatcher implements ISyntaxNode {

		private var _index:int;
		private var _argument:ISyntaxNode;
		private var _property:String;

		/**
		 * Constrcutor.
		 */
		public function IndirectionNode(argument:ISyntaxNode, property:String, index:int) {
			_argument=argument;
			_property=property;
			_index=index;

			_argument.addEventListener(Event.CHANGE, onArgumentChange);
		}

		/**
		 * Argument change.
		 */
		private function onArgumentChange(event:Event):void {
			dispatchEvent(new Event(Event.CHANGE))
		}

		/**
		 * Get value.
		 */
		public function get value():Object {
			return _argument.value[_property];
		}

		/**
		 * Get index.
		 */
		public function get index():int {
			return _index;
		}
	}
}